
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>系统路由 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="AJAX.html" />
    
    
    <link rel="prev" href="PAGE.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="START.html">
            
                <a href="START.html">
            
                    
                    快速开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="MENU.html">
            
                <a href="MENU.html">
            
                    
                    菜单配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="PAGE.html">
            
                <a href="PAGE.html">
            
                    
                    页面开发
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5" data-path="ROUTE.html">
            
                <a href="ROUTE.html">
            
                    
                    系统路由
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="AJAX.html">
            
                <a href="AJAX.html">
            
                    
                    Ajax请求
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="MOCK.html">
            
                <a href="MOCK.html">
            
                    
                    Mock模拟数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="STYLE.html">
            
                <a href="STYLE.html">
            
                    
                    样式&主题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="LAYOUT.html">
            
                <a href="LAYOUT.html">
            
                    
                    导航布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="MODEL.html">
            
                <a href="MODEL.html">
            
                    
                    Model(Redux)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="I18N.html">
            
                <a href="I18N.html">
            
                    
                    国际化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="PERMISSION.html">
            
                <a href="PERMISSION.html">
            
                    
                    权限控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="NGINX.html">
            
                <a href="NGINX.html">
            
                    
                    Nginx配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="PROXY.html">
            
                <a href="PROXY.html">
            
                    
                    开发代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="OTHER.html">
            
                <a href="OTHER.html">
            
                    
                    其他
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >系统路由</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7CFB;&#x7EDF;&#x8DEF;&#x7531;">&#x7CFB;&#x7EDF;&#x8DEF;&#x7531;</h1>
<p>&#x7CFB;&#x7EDF;&#x8DEF;&#x7531;&#x4F7F;&#x7528; <a href="https://reacttraining.com/react-router/web/guides/quick-start" target="_blank">react-router</a>&#x3002;
&#x8DEF;&#x7531;&#x4F7F;&#x7528;&#x6700;&#x591A;&#x7684;&#x573A;&#x666F;&#x5C31;&#x662F;&#x4E00;&#x4E2A;path&#x5BF9;&#x5E94;&#x4E00;&#x4E2A;&#x9875;&#x9762;&#xFF0C;&#x4F46;&#x662F;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x4E0D;&#x5F97;&#x4E0D;&#x53BB;&#x7F16;&#x5199;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x591A;&#x4EBA;&#x534F;&#x4F5C;&#x65F6;&#xFF0C;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x8FD8;&#x7ECF;&#x5E38;&#x51B2;&#x7A81;&#x3002;
&#x7CFB;&#x7EDF;&#x901A;&#x8FC7;&#x811A;&#x672C;&#xFF0C;&#x7B80;&#x5316;&#x8DEF;&#x7531;&#x914D;&#x7F6E;&#x3002;</p>
<h2 id="&#x8DEF;&#x7531;&#x914D;&#x7F6E;&#x65B9;&#x5F0F;">&#x8DEF;&#x7531;&#x914D;&#x7F6E;&#x65B9;&#x5F0F;</h2>
<p>&#x901A;&#x8FC7;&#x811A;&#x672C;&#xFF0C;&#x81EA;&#x52A8;&#x6293;&#x53D6;&#xFF0C;&#x751F;&#x6210;<code>/src/pages/page-routes.js</code>&#x6587;&#x4EF6;&#xFF0C;&#x652F;&#x6301;&#x4E24;&#x79CD;&#x5199;&#x6CD5;&#xFF1A;</p>
<ol>
<li>&#x5E38;&#x91CF;&#x65B9;&#x5F0F;<pre><code class="lang-js"> <span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> PAGE_ROUTE = <span class="hljs-string">&apos;/path&apos;</span>;
</code></pre>
</li>
<li>&#x9875;&#x9762;config&#x88C5;&#x9970;&#x5668;<pre><code class="lang-js"> @config({
     path: <span class="hljs-string">&apos;/path&apos;</span>,
 })
 <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SomePage</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">React</span>.<span class="hljs-title">Component</span> </span>{
     ...
 }
</code></pre>
</li>
</ol>
<p>&#x6BD4;&#x5982;SomePage.jsx&#x4E2D;&#x6709;&#x4E0A;&#x9762;&#x5176;&#x4E2D;&#x4EFB;&#x610F;&#x4E00;&#x79CD;&#x5199;&#x6CD5;&#xFF0C;&#x6700;&#x7EC8;&#x4F1A;&#x5728;<code>/src/pages/page-routes.js</code>&#x6587;&#x4EF6;&#x4E2D;&#x751F;&#x6210;&#x5982;&#x4E0B;&#x8DEF;&#x7531;&#x914D;&#x7F6E;&#xFF1A;</p>
<pre><code class="lang-js">{
    path: <span class="hljs-string">&apos;/path&apos;</span>,
    component: () =&gt; <span class="hljs-keyword">import</span>(<span class="hljs-string">&apos;/path/to/SomePage.jsx&apos;</span>),
},
</code></pre>
<h2 id="&#x4E8C;&#x7EA7;&#x9875;&#x9762;">&#x4E8C;&#x7EA7;&#x9875;&#x9762;</h2>
<p>&#x4E8C;&#x7EA7;&#x9875;&#x9762;&#x5982;&#x679C;&#x8981;&#x4FDD;&#x6301;&#x7236;&#x7EA7;&#x83DC;&#x5355;&#x7684;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#xFF0C;&#x4EE5;&#x7236;&#x7EA7;path&#x5F00;&#x59CB;&#x5E76;&#x4EE5;<code>/_/</code>&#x4F5C;&#x4E3A;&#x5206;&#x9694;&#x7B26;&#x5373;&#x53EF;&#xFF1A;<code>parent/path/_/child/path</code></p>
<pre><code class="lang-js"><span class="hljs-comment">// parent page </span>
@config({
    path: <span class="hljs-string">&apos;/parent/path&apos;</span>
})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Parent</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">React</span>.<span class="hljs-title">Component</span> </span>{
    ...
}

<span class="hljs-comment">// child page</span>
@config({
    path: <span class="hljs-string">&apos;/parent/path/_/child/path&apos;</span>
})
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Parent</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">React</span>.<span class="hljs-title">Component</span> </span>{
    ...
}
</code></pre>
<h2 id="&#x57DF;&#x540D;&#x5B50;&#x76EE;&#x5F55;&#x53D1;&#x5E03;&#x9879;&#x76EE;">&#x57DF;&#x540D;&#x5B50;&#x76EE;&#x5F55;&#x53D1;&#x5E03;&#x9879;&#x76EE;</h2>
<p>&#x5982;&#x679C;&#x9879;&#x76EE;&#x9700;&#x8981;&#x6302;&#x8F7D;&#x5230;&#x57DF;&#x540D;&#x7684;&#x4E00;&#x4E2A;&#x5B50;&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x6BD4;&#x5982; <code>http://xxx.com/react-admin</code>&#xFF0C;
&#x53EF;&#x4EE5;&#x4FEE;&#x6539;<code>src/router/AppRouter.jsx</code>&#x4E2D;&#x7684;<code>ROUTE_BASE_NAME</code>&#x5E38;&#x91CF;&#x3002;
&#x751F;&#x4EA7;&#x6784;&#x5EFA;&#x65F6;&#x6DFB;&#x52A0;PUBLIC_URL&#x53C2;&#x6570;&#xFF08;&#x5F00;&#x53D1;&#x65F6;&#x4E0D;&#x9700;&#x8981;&#xFF09;&#x3002;</p>
<p>&#x9879;&#x76EE;&#x5728;&#x5B50;&#x76EE;&#x5F55;react-admin&#x4E0B;&#xFF1A;</p>
<ol>
<li>&#x4FEE;&#x6539;&#x5E38;&#x91CF;<pre><code class="lang-js"> <span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> ROUTE_BASE_NAME = <span class="hljs-string">&apos;/react-admin&apos;</span>;
</code></pre>
</li>
<li>&#x751F;&#x4EA7;&#x6784;&#x5EFA;&#x6DFB;&#x52A0;&#x53C2;&#x6570;<pre><code class="lang-bash"> PUBLIC_URL=/react-admin yarn build
</code></pre>
</li>
</ol>
<p>&#x9879;&#x76EE;&#x76F4;&#x63A5;&#x6302;&#x8F7D;&#x57DF;&#x540D;&#x6839;&#x76EE;&#x5F55;&#xFF1A;(&#x65E0;&#x9700;PUBLIC_URL&#x53C2;&#x6570;)</p>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> ROUTE_BASE_NAME = <span class="hljs-string">&apos;&apos;</span>;
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="PAGE.html" class="navigation navigation-prev " aria-label="Previous page: 页面开发">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="AJAX.html" class="navigation navigation-next " aria-label="Next page: Ajax请求">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"系统路由","level":"1.5","depth":1,"next":{"title":"Ajax请求","level":"1.6","depth":1,"path":"AJAX.md","ref":"AJAX.md","articles":[]},"previous":{"title":"页面开发","level":"1.4","depth":1,"path":"PAGE.md","ref":"PAGE.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"ROUTE.md","mtime":"2019-02-17T03:20:18.930Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-02-17T03:27:10.809Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

